package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.rare;

import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;

public class RebuildSkill extends BaseSkill {
    public RebuildSkill(int level) {
        super(level);
    }

    public RebuildSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public RebuildSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setCooldown(10);
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("重组技能，不着火时候快速恢复生命。");
    }

    public SkillRarity getSkillRarity() {
        return SkillRarity.Rare;
    }

    public boolean canUseAbility(MobEntity mobEntity) {
        return (getSkilltime() < mobEntity.world.getTime());
    }

    @Override
    public boolean passiveApply(MobEntity mobEntity) {
        if (canUseAbility(mobEntity)) {
            if (!mobEntity.isOnFire()) {
                setSkilltime(mobEntity.world.getTime() + getCooldown());
                mobEntity.heal(getSkillLevel());
            }
        }
        return true;
    }
}
